function checkJsonLogin(r, cb) {
	if(r.code==-2) {
		alert(r.message); 
	} else {
		cb();
	}
}

Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

function getPrioritySpan(value) {
    if(value==0) {
      return '<span class="label label-default">默认</span>';
    } else if(value==10) {
      return '<span class="label label-success">轻度</span>';
    } else if(value==30) {
      return '<span class="label label-info">一般</span>';
    } else if(value==50) {
      return '<span class="label label-primary">重要</span>';
    } else if(value==70) {
      return '<span class="label label-warning">非常重要</span>';
    } else if(value==100) {
      return '<span class="label label-danger">紧急</span>';
    }
    return '';
}
function genProgressDiv(progress) {
    return '<div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="' + progress + '" aria-valuemin="0" aria-valuemax="100" style="width:' + progress + '%;">'
            + progress +'</div></div>';
}

function genSelectProgress(name,clazz,all,progress) {
    var html = '<select'
    if(name && name!='')
        html += ' name="' +name+ '"';
    if(clazz && clazz!='')
        html += ' class="' +clazz+ '"';
    html += ">"
    if(all)
        html += '<option value="">所有</option>';
    var a = [1,25,50,75,90,100];
    $.each(a,function(i,v){
        html += '<option value="'+v+'"';
        if(v==progress) {
            html += 'selected';
        }
        if(v==100)
            v = '完成';
        html += '>' + v + '%</option>';
    })
    return html;
}
function genSelectProgress(name,clazz,all,pid,progress) {
    var html = '<select'
    if(pid && pid!='')
        html += ' pid="' +pid+ '"';
    if(name && name!='')
        html += ' name="' +name+ '"';
    if(clazz && clazz!='')
        html += ' class="' +clazz+ '"';
    html += ">"
    if(all)
        html += '<option value="">所有</option>';
    var a = [1,25,50,75,90,100];
    $.each(a,function(i,v){
        html += '<option value="'+v+'"';
        if(v==progress) {
            html += 'selected';
        }
        if(v==100)
            v = '完成';
        else
            v = v + "%";
        html += '>' + v + '</option>';
    })
    html += '</select>'
    return html;
}
function genSelectPriority(name,clazz,all,pid,progress) {
    var html = '<select'
    if(pid && pid!='')
        html += ' pid="' +pid+ '"';
    if(name && name!='')
        html += ' name="' +name+ '"';
    if(clazz && clazz!='')
        html += ' class="' +clazz+ '"';
    html += ">"
    if(all)
        html += '<option value="">所有</option>';
    var a = [10,30,50,70,100];
    var b = ['轻度','一般','重要','非常重要','紧急'];
    $.each(a,function(i,v){
        html += '<option value="'+v+'"';
        if(v==progress) {
            html += 'selected';
        }
        html += '>' + b[i] + '</option>';
    })
    html += '</select>'
    return html;
}

